﻿using System;
using System.Text;
using WebMoney.Cryptography;

namespace WebMoney.WMSignerFX.KeysExtractor.Utils
{
    public static class MD4Hash
    {
        static readonly MD4 _md4 = new MD4();

        public static string GetHashString(string s)
        {
            if (string.IsNullOrEmpty(s))
                return null;

            byte[] baValue = Encoding.UTF8.GetBytes(s);

            byte[] baHash;

            lock (_md4)
            {
                _md4.Initialize();
                baHash = _md4.GetHash(baValue);
            }

            return BitConverter.ToString(baHash, 0).Replace("-", string.Empty);
        }
    }
}